<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:au="http://java.sun.com/jsf/composite/autocomplete">

    <ui:define name="content">
        <h:form>
            <p:panel header="Leave Application Form">
                <h:panelGrid columns="2" >
                    <p:panel header="Leave Form Details">
                        <h:panelGrid columns="2">                           
                            <h:outputLabel value="Staff : "/>
                            <au:completeStaff value="#{staffLeaveFromLateAndEarlyController.currentLeaveForm.staff}"/>
                            <h:outputLabel value="Leave Type"/>
                            <p:selectOneMenu  value="#{staffLeaveFromLateAndEarlyController.currentLeaveForm.leaveType}">
                                <f:selectItem itemLabel="Select Day Type"/>
                                <f:selectItems value="#{enumController.leaveType}"/>                                
                            </p:selectOneMenu>                                                                               
                            <p:commandButton ajax="false" value="Leave Count" action="#{staffLeaveFromLateAndEarlyController.calLeaveCount()}"/>
                            <h:panelGrid columns="3">
                                <h:outputLabel value="Leave Entitle || "/>
                                <h:outputLabel value="Leave Utilized || "/>
                                <h:outputLabel value="Ballance"/>
                                <h:outputLabel value="#{staffLeaveFromLateAndEarlyController.leaveEntitle}"/>
                                <h:outputLabel value="#{staffLeaveFromLateAndEarlyController.leaved}"/>
                                <h:outputLabel value="#{staffLeaveFromLateAndEarlyController.leaveEntitle - staffLeaveFromLateAndEarlyController.leaved}"/>
                            </h:panelGrid>

                            <h:panelGroup>
                                <h:outputText value="From Minute"/>
                                <p:inputText value="#{staffLeaveFromLateAndEarlyController.reportKeyWord.from}"/>
                                <h:outputText value="To Minute"/>
                                <p:inputText value="#{staffLeaveFromLateAndEarlyController.reportKeyWord.to}"/>
                                <p:commandButton ajax="false" value="Process Late and Early Shift" 
                                                action="#{staffLeaveFromLateAndEarlyController.fetchStaffShiftLateInErlyOut()}" />
                            </h:panelGroup>
                            <p:selectManyCheckbox id="s1" value="#{staffLeaveFromLateAndEarlyController.staffShiftsArray}"   >
                                <f:selectItem itemLabel="Select Staff Shift"/>
                                <f:selectItems value="#{staffLeaveFromLateAndEarlyController.staffShifts}"
                                               var="itm" itemLabel="#{itm.shiftDate}|#{itm.shift.name}" 
                                               itemValue="#{itm}" />
                            </p:selectManyCheckbox>
                            <h:outputLabel value="Comment"/>
                            <p:inputTextarea value="#{staffLeaveFromLateAndEarlyController.currentLeaveForm.comments}" />
                            <h:outputLabel/>
                            <h:panelGroup>
                                <p:commandButton id="btnAdd" ajax="false" value="Save" 
                                                   disabled="#{staffLeaveFromLateAndEarlyController.currentLeaveForm.id ne null}"
                                                action="#{staffLeaveFromLateAndEarlyController.saveLeaveform()}"/>

                                <p:commandButton ajax="false" value="Clear" 
                                                action="#{staffLeaveFromLateAndEarlyController.clear}"/>
                                <p:commandButton ajax="false" value="Delete" 
                                                action="#{staffLeaveFromLateAndEarlyController.deleteLeaveForm()}"/>
                            </h:panelGroup>                     
                        </h:panelGrid>
                    </p:panel> 
                    <p:panel header="Search Leave Forms" >
                        <p:panel>
                            <p:panelGrid columns="2" >
                                <h:outputLabel value="From Date"/>
                                <p:calendar value="#{staffLeaveFromLateAndEarlyController.fromDate}"
                                            pattern="dd MMMM yyyy">     
                                </p:calendar>   
                                <h:outputLabel value="To Date"/>
                                <p:calendar value="#{staffLeaveFromLateAndEarlyController.toDate}"
                                            pattern="dd MMMM yyyy">
                                </p:calendar> 
                                <h:outputLabel value="Staff : "/>
                                <au:completeStaff value="#{staffLeaveFromLateAndEarlyController.staff}"/>                               
                                <h:outputLabel value="Leave Type"/>
                                <p:selectOneMenu  value="#{staffLeaveFromLateAndEarlyController.leaveType}">
                                    <f:selectItem itemLabel="Select Day Type"/>
                                    <f:selectItems value="#{enumController.leaveType}"/>
                                </p:selectOneMenu>                                                     
                                <p:commandButton value="Search Created Date" ajax="false" action="#{staffLeaveFromLateAndEarlyController.createleaveTable()}" />
                                <p:commandButton value="Search Approved Date" ajax="false" action="#{staffLeaveFromLateAndEarlyController.createleaveTableApprovedDate()}" />
                            </p:panelGrid>
                        </p:panel>
                        <p:panel>
                            <p:dataTable value="#{staffLeaveFromLateAndEarlyController.leaveForms}" var="l" 
                                         rowStyleClass="#{l.retired eq true ? 'redText':''}"
                                         scrollable="true"
                                         scrollHeight="300" >
                                <p:column headerText="View" >
                                    <p:commandButton ajax="false" value="View" action="#{staffLeaveFromLateAndEarlyController.viewLeaveForm(l)}" disabled="#{l.retired}"></p:commandButton>
                                </p:column>
                                <p:column headerText="Staff">
                                    <p:outputLabel value="#{l.staff.person.nameWithTitle}" ></p:outputLabel>
                                </p:column>
                                <p:column headerText="From">
                                    <p:outputLabel value="#{l.fromDate}" >
                                        <f:convertDateTime pattern="yyyy MM dd HH:mm:ss" />
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="To">
                                    <p:outputLabel value="#{l.toDate}" >
                                        <f:convertDateTime pattern="yyyy MM dd HH:mm:ss" />
                                    </p:outputLabel>
                                </p:column>
                                <p:column headerText="Aproved By">
                                    <p:outputLabel value="#{l.approvedStaff.person.nameWithTitle}" ></p:outputLabel>
                                </p:column>
                                <p:column headerText="Comment">
                                    <p:outputLabel value="#{l.comments}" ></p:outputLabel>
                                </p:column>
                                <p:column headerText="Creater">
                                    <p:outputLabel value="#{l.creater.webUserPerson.nameWithTitle}" ></p:outputLabel>
                                    <br></br>
                                    <p:outputLabel value="Deleted By  #{l.retirer.webUserPerson.nameWithTitle}" rendered="#{l.retired}" style="color: blue;"/>
                                </p:column>
                            </p:dataTable>
                        </p:panel>
                    </p:panel>
                </h:panelGrid>              
            </p:panel>
        </h:form>
    </ui:define> 

</ui:composition>
